﻿#ifndef __GAF_PLAYER_H__
#define __GAF_PLAYER_H__

namespace GAF
{
	class PlayerResponse;
	class Player;
}
typedef GAF::PlayerResponse		GAF_IPlayerResponse;
typedef GAF::Player			GAF_CPlayer;

namespace GAF
{
	enum PlayerState
	{
		PLAYER_PLAY,
		PLAYER_PAUSE,
		PLAYER_STOP,
		PLAYER_OTHER
	};
}
typedef GAF::PlayerState		GAF_EPlayerState;
#define GAF_PLAYER_PLAY			GAF::PLAYER_PLAY
#define GAF_PLAYER_PAUSE		GAF::PLAYER_PAUSE
#define GAF_PLAYER_STOP			GAF::PLAYER_STOP


#include "GAF_Define.h"
#include "GAF_Bundle.h"

namespace GAF
{
	/// 动画效果响应处理接口
	class _INTERFACE PlayerResponse
	{
	public:
		/// 当播放对象响应时
		virtual void		OnPlayerResponse(GAF_CPlayer* pPlayer, UINT nState) = 0;
	};

	/// 可播放对象基类
	class _ABSTRACT Player
	{
	private:
		// 自动名称序号
		static UINT		GetID();
		static UINT		m_nID;

	public:
		Player();
		virtual ~Player();

	public:
		/// 设置响应处理类
		void			SetResponse(PlayerResponse* pResponse);

		/// 播放对象
		void			Play(Bundle* pParam = NULL);
		/// 暂停对象
		void			Pause();
		/// 停止对象
		void			Stop();

	protected:
		/// 播放对象操作
		virtual bool		Playing(GAF_CBundle* pParam) = 0;
		/// 暂停对象操作
		virtual bool		Pauseing() = 0;
		/// 停止对象操作
		virtual bool		Stoping() = 0;

		/**
		 *  @name 事件成员
		 */
		// 定义事件
	protected:
		/// 当播放对象时
		virtual bool		OnPlay(GAF_CBundle* pParam)
					{return true;}
		/// 当暂停对象时
		virtual bool		OnPause()
					{return true;}
		/// 当停止对象时
		virtual bool		OnStop()
					{return true;}

	public:
		/// 名字属性
		DIM_ATTRIB_R(_STRING, PlayerName);
		/// 动画效果状态属性
		DIM_ATTRIB_R(UINT, State);
		/// 循环属性
		DIM_ATTRIB(bool, Loop);

	public:
		/// 设置播放对象名称
		void			SetPlayerName(_STRING strPlayerName);

	protected:
		/// 播放对象响应对象
		PlayerResponse*		m_pResponse;
	};
}

#endif